<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<body>
<aside class="main-sidebar" th:fragment="menu">
    <!-- sidebar: style can be found in sidebar.less -->
    <section class="sidebar">
        <!-- Sidebar user panel -->
        <div class="user-panel">
            <div class="pull-left image">
                <img th:src="@{/static/images/head-img.jpeg}" class="img-circle" alt="User Image">
            </div>
            <div class="pull-left info">
                <p th:text="${currentUser == null ? '' : currentUser.realName}"></p>
                <a href="#"><i class="fa fa-circle text-success"></i> <th:block th:if="${currentUser != null}" th:text="${currentUser.level == 0 ? '超级管理员' : (currentUser.level == 1 ? '管理员' : '成员') }"/></a>
            </div>
        </div>
        <!-- sidebar menu: : style can be found in sidebar.less -->
        <ul class="sidebar-menu" data-widget="tree">
            <li class="header">印刷ERP</li>
            <th:block th:each="res : ${resources}">
            <li th:id="${res.id}" th:if="${#lists.size(res.subResources) > 0}" class="treeview">
                <a href="#">
                    <i th:class="*{res.icon}"></i>
                    <span th:text="*{res.name}"></span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li class="menuli" th:data-pid="${item.parentId}" th:data-url="${item.url}" th:each="item : ${res.subResources}"><a th:href="@{${item.url}}"><i class="fa fa-circle-o"></i><th:block th:text="${item.name}"/></a></li>
                </ul>
            </li>
            <li th:if="${#lists.size(res.subResources) == 0}"><a th:href="@{${res.url}}"><i class="fa fa-book"></i> <span th:text="${res.name}"></span></a></li>
            </th:block>
        </ul>
    </section>
    <!-- /.sidebar -->
    <script th:inline="javascript">
        $(document).ready(function () {
            var url = [[${#request.getRequestURI()}]];
            $("li.treeview").attr("class","treeview");
            $("li.menuli").prop("class");

            $("li.menuli").each(function () {
                var dataUrl = $(this).data("url");
                var pid = $(this).data("pid");
                if(dataUrl == url) {
                    $("#" + pid).attr("class", "treeview active");
                    $(this).attr("class", "active");
                }
            });
        });
    </script>
</aside>
</body>
</html>